<template>
<div class="foundation">
	<ul class="info clearfix">
		<li>
			<div class="clearfix box" v-if="Community.length !== 0">
                <div class="img"><img :src="imgUrl + Icommunity.photo" width="100%" /></div>
				<div class="detail">
					<p class="name">{{$i18n.locale == 'zh'?Icommunity.zhName || $lang('No_data'):Icommunity.enName || $lang('No_data')}}</p>
					<p class="base_info">{{$i18n.locale == 'zh'?Icommunity.zhSimpleIntro || $lang('No_data'):Icommunity.enSimpleIntro || $lang('No_data')}}</p>
					<div class="person_introd">
						<span>{{ $lang('PERSON_INTRODUCE') }}</span>
						<div>
							<p>{{$i18n.locale == 'zh'?Icommunity.zhDetailIntro || $lang('No_data'):Icommunity.enDetailIntro || $lang('No_data')}}</p>
						</div>
					</div>
					<div class="pagination" v-if="Community">
						<el-pagination :current-page="currentPage"
                            layout="prev, pager, next"
                            :total="Community.length*10"
                            @current-change="pagination">
					    </el-pagination>
					</div>
					<button class="donation" v-if="Icommunity.donationAmount !== null">{{ $lang('DONATION') }}: {{Icommunity.donationAmount}}</button>
				</div>
			</div>
            <div class="clearfix box" v-else>
                <div class="noM">{{ $lang('No_information')}}</div>
            </div>
		</li>
	</ul>
</div>
</template>

<script>
import { gets } from "@/api/api.js";
export default {
	data(){
		return {
            Community: [],
            Icommunity: [],
            currentPage:1, // 分页当前页
            cIndex: 0,
            imgUrl:'https://equfile.s3.us-east-2.amazonaws.com/'
        }
    },
    props: ['teamType'],
	methods:{
        async getCommunity(idx) {
            let that = this
            try {
                let res = await gets.searchCompanyList("/community/find-team-info.json", {
                    companyId : that.$store.state.common.companyId,
                    teamType  : idx
                });
                that.Community = res.listData
                that.Icommunity = that.Community[that.cIndex]  
                that.currentPage = that.cIndex 
            } catch (e) {
                console.log(e)
                throw e;
            }
        },
        pagination (type) {
            let that = this
            that.currentPage = type
            that.Icommunity = that.Community[type-1]    
        }
	},
	components:{
    },
    created() {
        this.getCommunity(this.teamType)
    },
}
</script>

<style lang="scss">
.foundation{
    .box{
        .img{
            width: 200px;
        }
    }
}
.noM{
    color: #fff;
    text-align: center;
}
.el-pager li.btn-quicknext, .el-pager li.btn-quickprev{
    color: #fff;
}
</style>